using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Xml.Xsl;


/// <summary>
/// Summary description for xmlCongTy
/// </summary>
public class xmlCongTy
{

    const string congtyXmlFileConfig = "CongTyXml";

    public static string xmlCongTyFile
    {
        get
        {
            string s;
            s = ConfigurationManager.AppSettings[congtyXmlFileConfig];
            return s;
        }
    }

    public static XmlDocument getXMLCongTy(string FileName)
    {
        XmlDocument kq;
        kq = xmlCommon.read(FileName);
        return kq;
    }
    public static bool saveXMLCongTy(XmlDocument xmDoc, string FileName)
    {
        bool kq;
        kq = xmlCommon.write(xmDoc, FileName);
        return kq;
    }
    public CongTy_Info getCongTy(string FileName)
    {
        XmlDocument xmlDoc;
        xmlDoc = getXMLCongTy(FileName);
        CongTy_Info kq = new CongTy_Info();
        try
        {
            kq.Ten = xmlDoc.ChildNodes[0].ChildNodes[0].InnerText;
            kq.DiaChi = xmlDoc.ChildNodes[0].ChildNodes[1].InnerText;
            kq.DienThoai = xmlDoc.ChildNodes[0].ChildNodes[2].InnerText;
            kq.EmailAdmin = xmlDoc.ChildNodes[0].ChildNodes[3].InnerText;
            kq.Logo = xmlDoc.ChildNodes[0].ChildNodes[4].InnerText;
            kq.Banner = xmlDoc.ChildNodes[0].ChildNodes[5].InnerText;
            kq.GioiThieu = xmlDoc.ChildNodes[0].ChildNodes[6].InnerText;
         }
         catch (Exception ex)
         {
            kq = null;
         }
         return kq;
    }
    public bool updateCongTy(CongTy_Info oCongTy, string FileName)
    {
         //bool kq = true;
         XmlDocument xmldoc = new XmlDocument();
         xmldoc.Load(FileName);
         {
            xmldoc.ChildNodes[0].ChildNodes[0].InnerText = oCongTy.Ten;
            xmldoc.ChildNodes[0].ChildNodes[1].InnerText = oCongTy.DiaChi;
            xmldoc.ChildNodes[0].ChildNodes[2].InnerText = oCongTy.DienThoai;
            xmldoc.ChildNodes[0].ChildNodes[3].InnerText = oCongTy.EmailAdmin;
            xmldoc.ChildNodes[0].ChildNodes[4].InnerText = oCongTy.Logo;
            xmldoc.ChildNodes[0].ChildNodes[5].InnerText = oCongTy.Banner;
            xmldoc.ChildNodes[0].ChildNodes[6].InnerText = oCongTy.GioiThieu;
         }
         return saveXMLCongTy(xmldoc, FileName);
    }

	public xmlCongTy()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
